package com.cr.web.controller.lsd;

import com.alibaba.fastjson2.JSON;
import com.cr.business.service.ITbSupervisionRankingInfoService;
import com.cr.common.core.domain.AjaxResult;
import com.cr.sync.service.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/lsd/index")
@Validated
public class LsdIndexController {

    @Resource
    private ITbSyncProductionCertificateService tbSyncProductionCertificateService;

    @Resource
    private ITbSyncDetectionSamplingService tbSyncDetectionSamplingService;

    @Resource
    private ITbSyncMainBodyInfoService tbSyncMainBodyInfoService;

    @Resource
    private LsdCountService lsdCountService;

    @Resource
    private ITbServiceStationInfoService tbServiceStationInfoService;

    @Resource
    private ITbSupervisionRankingInfoService tbSupervisionRankingInfoService;

    /**
     * 合格证相关统计
     * @return
     */
    @GetMapping("productionCertificateCount")
    public AjaxResult getProductionCertificateCount(String area) {
        return AjaxResult.success(tbSyncProductionCertificateService.getLsdIndexCountInfo(area));
    }

    /**
     * 主体相关统计
     * @return
     */
    @GetMapping("mainBodyCount")
    public AjaxResult getMainBodyCount(String area) {
        return AjaxResult.success(tbSyncMainBodyInfoService.getIndexMainBodyCount(area));
    }

    /**
     * 检测相关统计
     * @return
     */
    @GetMapping("detectionSamplingCount")
    public AjaxResult getDetectionSamplingCount(String area) {
        return AjaxResult.success(tbSyncDetectionSamplingService.getDetectionSamplingCount(area));
    }

    /**
     * 区域相关统计
     * @param area 地区名
     */
    @GetMapping("areaCount")
    public AjaxResult getAreaCount(String area) {
        return AjaxResult.success(lsdCountService.getAreaCount(area));
    }

    /**
     * 乡镇速测室及合格证服务站查询接口
     * @param area 地区
     */
    @GetMapping("serviceStation")
    public AjaxResult getServiceStationList(String area) {
        return AjaxResult.success(tbServiceStationInfoService.getLsdList(area));
    }

    /**
     * 获取监管排名列表
     */
    @GetMapping("rankingList")
    public AjaxResult rankingList(){
        return AjaxResult.success(tbSupervisionRankingInfoService.getLsdList());
    }

}
